package com.easylinkin.sm.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.easylinkin.sm.entity.Role;

/**
 * 角色Mapper
 *
 * @author majintao
 * @since 1.0.0, 2019/8/23
 */
@Mapper
public interface RoleMapper extends BaseMapper<Role> {

  Role getById(@Param("id") Long id);
  
  /**
   * 按用户查询
   *
   * @param userId 用户编号
   * @return 角色集合
   */
  @Select("select a.* from sm_role a JOIN sm_user_ref_role b where b.role_id = a.role_id_ and b.user_id = #{userId}")
  List<Role> findByUsersId(Long userId);
  
}
